-- vim.uv 示例: 重复计时器
-- Create a timer handle (implementation detail: uv_timer_t).
-- local timer = vim.uv.new_timer() -- 原文档用的vim.uv, 值是nil
local timer = vim.loop.new_timer()
local i = 0
-- Waits 1000ms, then repeats every 750ms until timer:close().
timer:start(1000, 750, function()
	print("timer invoked! i=" .. tostring(i))
	if i > 4 then
		timer:close() -- Always close handles to avoid leaks.
	end
	i = i + 1
end)
print("sleeping")


-- 使用 :luafile % 执行
